﻿namespace Home
{
    using System;
    using System.Collections.Generic;
    using System.Data.Common;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    public static class BusinessHelper
    {
        public static async Task<IReadOnlyList<string>> RetrieveEmployeesAsync(DbConnection connection)
        {
            var result = new List<string>();

            var reader = default(DbDataReader);
            try
            {
                reader = await connection.ExecuteReaderAsync("SELECT [full_name] FROM tc_employee");
                while (await reader.ReadAsync())
                {
                    result.Add(reader.GetString(0));
                }
            }
            finally
            {
                if (reader != null) reader.Dispose();
            }

            return result;
        }
    }
}
